// 数据库配置
const Sequelize = require('sequelize')

//  数据库：databsedemo 账户：root 密码：admin123456
const sequelize = new Sequelize('databsedemo', 'root', 'admin123456', {
    host: 'localhost',
    port: 3306,// 数据库链接端口
    dialect: 'mysql',
    dialectOptions: {
        socketPath: '/tmp/mysql.sock' // 指定套接字文件路径
    },
    operatorsAliases: false,
    pool: {
        max: 5,
        min: 0,
        acquire: 30000,
        idle: 10000
    }
})
sequelize.authenticate().then(() => {
    console.log('数据库链接成功......')
}).catch(err => {
    console.error('链接失败:', err)
})
// 根据模型自动创建表
sequelize.sync()

module.exports = sequelize
